package com.tarena.lbs.stock.web.repository;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tarena.lbs.pojo.stock.po.CouponStockPO;
import com.tarena.lbs.stock.web.mapper.StockMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
public class StockRepository extends ServiceImpl<StockMapper, CouponStockPO> {
    @Autowired
    private StockMapper stockMapper;
    public boolean updateCouponStock(Integer couponId, Integer num) {
        CouponStockPO poParam=new CouponStockPO();
        poParam.setCouponId(couponId);
        poParam.setNum(num);
        poParam.setUpdateAt(new Date());
        int result=stockMapper.updateCouponStock(poParam);
        return result>0;//sql执行影响的行数 大于0 说明执行成功 等于0 执行失败
    }
}
